package org.jeecg.modules.activiti.listener;

import com.alibaba.fastjson.JSON;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.LdProjectInfo.entity.LdProjectInfo;
import org.jeecg.modules.LdProjectInfo.service.ILdProjectInfoService;
import org.jeecg.modules.LdProjectInfo.service.impl.LdProjectInfoServiceImpl;
import org.jeecg.modules.activiti.entity.ActBusiness;
import org.jeecg.modules.activiti.service.IActBusinessService;
import org.jeecg.modules.zcgl.entity.AssetFixed;
import org.jeecg.modules.zcgl.service.IAssetFixedService;
import org.jeecg.modules.zcglRecipients.entity.ZcglRecipientsAssets;
import org.jeecg.modules.zcglRecipients.service.IZcglRecipientsService;
import org.jeecg.modules.zcglRecipients.vo.ZcglRecipientsPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class BjListener implements ExecutionListener {
     ILdProjectInfoService ldProjectInfoService;
    IActBusinessService actBusinessService;

    @Override
    public void notify(DelegateExecution execution) throws Exception {
        if (actBusinessService == null) {
            actBusinessService = (IActBusinessService) SpringContextUtils.getBean("actBusinessServiceImpl");
        }
        if (ldProjectInfoService == null) {
            ldProjectInfoService = (LdProjectInfoServiceImpl) SpringContextUtils.getBean("ldProjectInfoServiceImpl");
        }

        String eventName = execution.getEventName();
        //start
        if (EVENTNAME_START.equals(eventName)) {

        } else if (EVENTNAME_END.equals(eventName)) {
            ActBusiness actBusiness = actBusinessService.getById(execution.getProcessBusinessKey());
                if (actBusiness != null && "ld_project_info".equalsIgnoreCase(actBusiness.getTableName())){
                    LdProjectInfo page = JSON.parseObject(actBusiness.getData(), LdProjectInfo.class);


                }

        }
    }
}
